//
//  statusCellTop.swift
//  MicroBlog
//
//  Created by QT on 15/8/2.
//  Copyright © 2015年 綦敦涛. All rights reserved.
//

import UIKit
import SDWebImage
class statusCellTop: UIView {

    var Tstatus: status?{
        didSet{
            if let url = Tstatus?.User?.profileImageRUL{
                iconView.sd_setImageWithURL(url)
            }
            nameLab.text  = Tstatus?.User?.name
            timeLab.text = "刚刚"
            sourceLab.text = "Sina微博客户端"
            memberIconView.image = Tstatus?.User?.verifiedImg
            vipIconView.image = Tstatus?.User?.mbrankImg
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
     backgroundColor = UIColor.clearColor()
        setUpUi()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    private func setUpUi(){
        // 添加分割线
        let sepV = UIView()
        addSubview(sepV)
        sepV.backgroundColor  = UIColor(white: 0.8, alpha: 1)
        sepV.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: UIScreen.mainScreen().bounds.width, height: 10))
        
        
        
        addSubview(iconView)
        addSubview(nameLab)
        addSubview(timeLab)
        addSubview(sourceLab)
        addSubview(memberIconView)
        addSubview(vipIconView)
        
        // 设置布局
        
        iconView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: sepV, size: CGSize(width: 35, height: 35), offset: CGPoint(x: 8, y: 8))
        
        nameLab.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: 12, y: 0))
        timeLab.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 12, y: 0))
        sourceLab.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: timeLab, size: nil, offset: CGPoint(x: 12, y: 0))
        memberIconView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: 8, y: 8))
        vipIconView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: nameLab, size: nil, offset: CGPoint(x: 12, y: 0))
    }
    
    
    // MARK: -懒加载控件
    // 头像
    private lazy var iconView: UIImageView = UIImageView()
    // 昵称
    private lazy var nameLab: UILabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 15)
    // 发送时间
    private lazy var timeLab: UILabel = UILabel(color: UIColor.orangeColor(), fontSize: 9)
    // 发送端
    private lazy var sourceLab: UILabel = UILabel(color: UIColor.lightGrayColor(), fontSize: 9)
    // 会员图标
    private lazy var memberIconView: UIImageView = UIImageView(image: UIImage(named:"avatar_vip"))
    // VIP图标
    private lazy var vipIconView: UIImageView = UIImageView(image: UIImage(named: "common_icon_membership_level1"))
}


